package com.cy.pj.goods.controller;

import com.cy.pj.goods.pojo.Goods;
import com.cy.pj.goods.service.GoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/goods/")
public class JsonGoodsController {
    @Autowired
    private GoodsService goodsService;
    @GetMapping("doFindJsonGoods")
    @ResponseBody
    public JsonResult doFindJsonGoods(String name){
        List<Goods> list = goodsService.findGoods(name);
        return new JsonResult(list);
    }
    @GetMapping("doSaveJsonGoods")
    @ResponseBody
    public JsonResult doSaveJsonGoods(@RequestBody Goods goods){
        goodsService.saveGoods(goods);
        return new JsonResult(goods);
    }
}
